import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";

/*
 * storeRoomService - 库房
 * @date: 2018/10/13 10:42:18

 */
import request from 'utils/request';
import { getCurrentOrganizationId, parseParameters } from 'utils/utils';
import { CPAAS_PLATFORM } from 'utils/config';
var organizationId = getCurrentOrganizationId();
/**
 * 查询库房列表的数据
 * @param {Object} params - 查询参数
 * @param {String} params.page - 页码
 * @param {String} params.size - 页数
 * @param {String} params.companyId - 公司编码
 */

export function queryStoreRoom(_x) {
  return _queryStoreRoom.apply(this, arguments);
}

function _queryStoreRoom() {
  _queryStoreRoom = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(params) {
    var param;
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            param = parseParameters(params);
            return _context.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(organizationId, "/inventories"), {
              method: 'GET',
              query: param
            }));

          case 2:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));
  return _queryStoreRoom.apply(this, arguments);
}

export function saveStoreRoom(_x2) {
  return _saveStoreRoom.apply(this, arguments);
}

function _saveStoreRoom() {
  _saveStoreRoom = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(params) {
    return _regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            return _context2.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(organizationId, "/inventories/batch-save"), {
              method: 'POST',
              body: params
            }));

          case 1:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  }));
  return _saveStoreRoom.apply(this, arguments);
}